﻿using System;
using System.Threading.Tasks;

namespace WebMiddleware
{
    internal class ApplicationTaskProxy : ITaskProxy
    {
        private readonly WpfApplication _app;

        public ApplicationTaskProxy(WpfApplication app)
        {
            _app = app;
        }

        public async Task InvokeAsync(Action action)
        {
            await _app.Dispatcher.InvokeAsync(action);
        }

        public async Task<TResult> InvokeAsync<TResult>(Func<TResult> func)
        {
            return await _app.Dispatcher.InvokeAsync(func);
        }
    }
}
